package com.zhiwang.planet.mvvm.viewmodel.zygote

import androidx.lifecycle.MutableLiveData
import androidx.paging.DataSource
import com.zhiwang.planet.mvvm.model.RestApi

abstract class SimplePageKeyedDataSourceFactory<KEY, VALUE> constructor(val restApi: RestApi) : DataSource.Factory<KEY, VALUE>() {

    val sourceLiveData = MutableLiveData<SimplePageKeyedDataSource<KEY, VALUE>>()

    override fun create(): DataSource<KEY, VALUE> {

        val source = createDataSource()

        sourceLiveData.postValue(source)
        return source
    }


    abstract fun createDataSource(): SimplePageKeyedDataSource<KEY, VALUE>
}


